<jcpsm:pageContainer>
<c:if test="${not empty sessionScope.isUserLoggedIn && empty sessionScope.admin}">
	<jsp:forward page="/profile/home.jsp"></jsp:forward>
</c:if>
<c:if test="${empty sessionScope.isUserLoggedIn && empty sessionScope.admin}">
	<jsp:forward page="/index.jsp"></jsp:forward>
</c:if>
<div class="content">
<h1 class="title">Manage <span>Schedule</span></h1>
<div >
<div class="">
<c:if test="${not empty sessionScope.userTimelineDTO}">

<table width="100%">
	<tr>
		<td width="33%" align="left"><a style="font-size: 11px; font-weight: bold; font-family: Verdana" title="${session.userTimelineDTO.previousWeekId}" href="${contextRoot}/loadSchedule?weekId=${session.userTimelineDTO.previousWeekId}">Previous Week</a></td>
		<td width="33%" align="center"><span style="font-size: 11px; font-weight: bold; font-family: Verdana"><c:out value="${sessionScope.userTimelineDTO.currentWeekId}"/></span></td>
		<td width="33%" align="right"><a style="font-size: 11px; font-weight: bold; font-family: Verdana"	 title="${session.userTimelineDTO.nextWeekId}" href="${contextRoot}/loadSchedule?weekId=${session.userTimelineDTO.nextWeekId}">Next Week</a></td>
	</tr>
</table>
</c:if>


<c:if test="${not empty sessionScope.userTimelineDTO.userTimelineRowList}">
<table class="gridtable"  style="box-shadow: 5px 5px 8px #888888;">	
	<tr class="fillgray">
			<td rowspan="2" class="border bold">Sl No</td>
			<td rowspan="2" class="border bold">Name</td>
			<td rowspan="2" class="border bold">Track</td>
			<td class="heading fillgray" align="center" >Saturday</td>
			<td class="heading  fillgray" align="center" >Sunday</td>
			<td class="heading" align="center">Monday</td>
			<td class="heading" align="center">Tuesday</td>
			<td class="heading" align="center">Wednesday</td>
			<td class="heading" align="center">Thursday</td>
			<td class="heading" align="center">Friday</td>
		</tr>
		<tr>
		<c:forEach var="nextDay" items="${sessionScope.userTimelineDTO.nextSevenDaysList}" varStatus="dayCount">
			<td class="fillgray" style="" class=" <c:if test="${dayCount.index < 2 }"></c:if>">${nextDay}</td>
		</c:forEach>
		</tr>
	
	
	<c:if test="${not empty sessionScope.userTimelineDTO.userTimelineRowList}">
		<c:forEach var="userTimelineRow" items="${sessionScope.userTimelineDTO.userTimelineRowList}" varStatus="loop">
			
		<tr>
		<td align="center"> ${loop.index + 1}</td>
			<td align="center">
				${userTimelineRow.userName}
			</td>
			<td align="center">
			 <c:set var="primaryTrackId" value="${userTimelineRow.primaryTrack}" />
			${sessionScope.track[primaryTrackId].name}
			</td>
			<c:forEach var="userTimelineGrid" items="${userTimelineRow.userTimelineGridList}" varStatus="dayCount">
				<td class="grid_filler_general_shift <c:if test="${dayCount.index < 2 }"> fillWeekEnd </c:if> <c:if test="${not empty userTimelineGrid.timeLineId}"> filllightgray </c:if> ">
				
					<a href="javascript:void(0);" onclick="openUserDayEditor('${userTimelineGrid.userId}', '${userTimelineGrid.userName}','${userTimelineGrid.trackId}', '${userTimelineGrid.shiftId}', '${dayCount.index}', '${sessionScope.userTimelineDTO.currentWeekId}', '${loop.index}')" id="dayid_user" class="link_normal">
					${userTimelineGrid.trackName}<BR/><span <c:if test="${sessionScope.approvedUsers[userTimelineGrid.userId].compOffCount < 0 && ('Comp Off' eq userTimelineGrid.shiftName || 'Comp off' eq userTimelineGrid.shiftName)}">title='Not Eligible for Comp off' style='color:red; font-weight:bold'</c:if>>
					${userTimelineGrid.shiftName}	
					</span>
					</a>
					<input id="timeLine${loop.index}${dayCount.index}" value="${userTimelineGrid.timeLineId}#${userTimelineGrid.shiftId}" type="hidden"/>
					<c:if test="${not empty userTimelineGrid.timeLineId}">
					<a href="${contextRoot}/deleteSchedule?scheduleId=${userTimelineGrid.timeLineId}&weekId=${sessionScope.userTimelineDTO.currentWeekId}"><img src="${mediaRoot}/delete_icon.gif" width="13" height="13"></a>
					</c:if>
				</td>
			</c:forEach>
			
		</tr>
		</c:forEach>
	</c:if>
	
	
	
	
</table>
</c:if>
<div id="dayShiftEditor" style="display:none" class="day_shift_editor roundcornerdiv" >
<form id="manageScheduleForm" action="${contextRoot}/manageSchedle" onsubmit="return validate();">
<input id="formUserId" name="user" type="hidden" value=""/>
<input id="formWeekId" name="weekId" type="hidden" value=""/>

<input name="timeLineId0" id="timeLineId0" type="hidden" value=""/>
<input name="timeLineId1" id="timeLineId1" type="hidden" value=""/>
<input name="timeLineId2" id="timeLineId2" type="hidden" value=""/>
<input name="timeLineId3" id="timeLineId3" type="hidden" value=""/>
<input name="timeLineId4" id="timeLineId4" type="hidden" value=""/>
<input name="timeLineId5" id="timeLineId5" type="hidden" value=""/>
<input name="timeLineId6" id="timeLineId6" type="hidden" value=""/>

<div class="fltrgt">
	<a href="javascript: closeEditor();"><img src="${mediaRoot}/close_button.jpg"/></a>
</div>
<table class="preview_table" border="0">
		<tr>
			<td width="30%">
				Name
			</td>
			<td class="page_label">
				<span id="scheduleUserName"></span>
			</td>
		</tr>
		<tr>
			<td>
				<span id="sceduleTrackName">Track
			</td>
			<td>
				<select id="track_selector" name="track" class="syle_input width_200">
					<option value="-1">select</option>
					<c:forEach var="track" items="${sessionScope.track}">
						<c:if test="${track.value.deleteFlag eq false}">
							<option value="${track.value.trackId}">${track.value.name}</option>
						</c:if>
					</c:forEach>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				Shift
			</td>
			<td>
			<select id="shift_selector" name="shift" class="syle_input width_200">
					<option value="-1">select</option>
					<c:forEach var="shift" items="${sessionScope.shift}">
					<c:if test="${shift.value.deleteFlag eq false}">
						<option value="${shift.value.shiftId}">${shift.value.shiftName}</option>
						</c:if>
					</c:forEach>
				</select>
			</td>
		</tr>
			<tr style="margin-top: 10px">
				<td style="vertical-align: top;" align="left" width="class="">
				<div class="selectall"><div style="margin-left:34px"> Select All</div>
						<input id="selectall" title="Select All"  name="selectallBox" type="checkbox">
							<label for="selectall"  title="Select All"></label>
				</div>
						</td>
					
				
				<td>
					<table id="scheduleDays" style="width: 85%">
					
						<tr style="height: 15px">
							<td style="height: 15px" width="30%">
							<div class="dayIndex0"><div style="margin-left:25px; padding-top: 3px">Sat</div>
							<input name="dayIndex0" onclick="setTimeLineId(this,0);" id="dayIndex0" title="Saturday" type="checkbox" value="0">
							<label for="dayIndex0"  title="Saturday"></label>
											</div>
							</td>
							<td style="height: 15px">
										<div class="dayIndex3"><div style="margin-left:25px; padding-top: 3px">Tue</div>
										<input name="dayIndex3" onclick="setTimeLineId(3);"
											type="checkbox" id="dayIndex3" title="Tuesday"
											value="3"><label for="dayIndex3" title="Tuesday"></label>
											</div></td>
										<td style="height: 15px">
										<div class="dayIndex6"><div style="margin-left:25px; padding-top: 3px">Fri</div>
										<input name="dayIndex6" onclick="setTimeLineId(this,6);"
											type="checkbox" id="dayIndex6" title="Friday"
											value="6"><label for="dayIndex6" title="Friday"></label>
											</div></td>
									</tr>
									<tr style="height: 15px">
										<td style="height: 15px" width="30%">
										<div class="dayIndex1"><div style="margin-left:25px; padding-top: 3px">Sun</div>
										<input
											name="dayIndex1" type="checkbox" id="dayIndex1" title="Sunday" onclick="setTimeLineId(this,1);"
											value="1"><label for="dayIndex1" title="Sunday"></label>
											</div></td>

										<td style="height: 15px">
										<div class="dayIndex4"><div style="margin-left:25px; padding-top: 3px">Wed</div>
										<input name="dayIndex4"
											type="checkbox" id="dayIndex4" title="Wednesday" onclick="setTimeLineId(this,4);"
											value="4">
											<label for="dayIndex4" title="Wednesday"></label>
											</div></td>


									</tr>
									<tr style="height: 15px">

										<td style="height: 15px" width="30%">
										<div class="dayIndex2"><div style="margin-left:25px; padding-top: 3px">Mon</div>
										<input
											name="dayIndex2" id="dayIndex2" type="checkbox" title="Monday" onclick="setTimeLineId(this,2);"
											value="2"><label for="dayIndex2" title="Monday"></label>
											</div></td>
										<td style="height: 15px">
										<div class="dayIndex5"><div style="margin-left:25px; padding-top: 3px">Thu</div>
										<input name="dayIndex5"
											type="checkbox" id="dayIndex5" title="Thursday" onclick="setTimeLineId(this,5);"
											value="5"><label for="dayIndex5" title="Thursday"></label>
											</div></td>

										<td style="height: 15px">
										</td>
										<td style="height: 15px"></td>
						</tr>
					</table>

				</td>
			</tr>
			<tr>
			<td>
				&nbsp;
			</td>
			<td align="center"> 
				 <input type="submit" title="save" value="save" class="stylebutton mrglft100"></input>
			</td>
		</tr>
	</table>
	</form>
</div>
<div class="publish_button" style="margin-top: 25px;">
	<a title="Export" href="${contextRoot}/exportScheduleAsExcel?weekId=${sessionScope.userTimelineDTO.currentWeekId}" target="_new"><img title="Export to Excel" src="${mediaRoot}/excelexport.jpg" height="35" width="130" style="margin-right: 10px"/></a>
	<a href="${contextRoot}/publishSchedule?weekId=${sessionScope.userTimelineDTO.currentWeekId}">
		<img src="${mediaRoot}/publish.jpeg" width="65px" height="33px" title="publish"/>
	</a>
	
</div>
</div>
</div>
</div>
</jcpsm:pageContainer>
